package work.timejay.shop.controller.files;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import work.timejay.common.ApiResult;
import work.timejay.utils.FileUtils;

/**
 * @className:FileController.java
 * @author:王文杰
 * @version:1.0.0
 * @description:TODO
 * @createTime 2024年02月06日 17:55:00
 */
@RestController
@RequestMapping(value = "/api/file")
public class FileController {

    @Autowired
    private FileUtils fileUtils;

    /**
     * 文件上传
     */
    @PostMapping
    public ApiResult<String> upload(@RequestPart(value = "file") MultipartFile file) {
        String filePath = fileUtils.upload(file);
        return ApiResult.success(filePath);
    }
}
